package com.ruoyi.web.controller.classify;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.classify.domain.HsContentTag;
import com.ruoyi.classify.service.IHsContentTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 内容标签关联Controller
 *
 * @author lzk
 * @date 2025-06-17
 */
@RestController
@RequestMapping("/classify/classify")
@Tag(name = "【内容标签关联】管理")
public class HsContentTagController extends BaseController
{
    @Autowired
    private IHsContentTagService hsContentTagService;

    /**
     * 查询内容标签关联列表
     */
    @Operation(summary = "查询内容标签关联列表")
    @PreAuthorize("@ss.hasPermi('classify:classify:list')")
    @GetMapping("/list")
    public TableDataInfo list(HsContentTag hsContentTag)
    {
        startPage();
        List<HsContentTag> list = hsContentTagService.selectHsContentTagList(hsContentTag);
        return getDataTable(list);
    }

    /**
     * 导出内容标签关联列表
     */
    @Operation(summary = "导出内容标签关联列表")
    @PreAuthorize("@ss.hasPermi('classify:classify:export')")
    @Log(title = "内容标签关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HsContentTag hsContentTag)
    {
        List<HsContentTag> list = hsContentTagService.selectHsContentTagList(hsContentTag);
        ExcelUtil<HsContentTag> util = new ExcelUtil<HsContentTag>(HsContentTag.class);
        util.exportExcel(response, list, "内容标签关联数据");
    }

    /**
     * 获取内容标签关联详细信息
     */
    @Operation(summary = "获取内容标签关联详细信息")
    @PreAuthorize("@ss.hasPermi('classify:classify:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hsContentTagService.selectHsContentTagById(id));
    }

    /**
     * 新增内容标签关联
     */
    @Operation(summary = "新增内容标签关联")
    @PreAuthorize("@ss.hasPermi('classify:classify:add')")
    @Log(title = "内容标签关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HsContentTag hsContentTag)
    {
        return toAjax(hsContentTagService.insertHsContentTag(hsContentTag));
    }

    /**
     * 修改内容标签关联
     */
    @Operation(summary = "修改内容标签关联")
    @PreAuthorize("@ss.hasPermi('classify:classify:edit')")
    @Log(title = "内容标签关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HsContentTag hsContentTag)
    {
        return toAjax(hsContentTagService.updateHsContentTag(hsContentTag));
    }

    /**
     * 删除内容标签关联
     */
    @Operation(summary = "删除内容标签关联")
    @PreAuthorize("@ss.hasPermi('classify:classify:remove')")
    @Log(title = "内容标签关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable( name = "ids" ) Long[] ids)
    {
        return toAjax(hsContentTagService.deleteHsContentTagByIds(ids));
    }

    @PostMapping("/batchVerify")
    public AjaxResult batchVerify(@RequestBody List<Long> ids) {
        return toAjax(hsContentTagService.batchUpdateVerify(ids, 1));
    }

    @PostMapping("/batchUnverify")
    public AjaxResult batchUnverify(@RequestBody List<Long> ids) {
        return toAjax(hsContentTagService.batchUpdateVerify(ids, 0));
    }

}
